<template>
  <div class="user">
    <div class="top">
      <div class="titletext">客户管理</div>
      <div class="search">
        <el-form :inline="true" :model="search" class="demo-form-inline">
          <el-form-item label="客户ID">
            <el-input v-model="search.id" />
          </el-form-item>
          <el-form-item label="客户名称">
            <el-input v-model="search.user" />
          </el-form-item>
          <el-form-item label="IC卡号">
            <el-input v-model="search.user" />
          </el-form-item>
          <el-form-item>
            <el-button @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="list" v-if="cusomerList && cusomerList.list">
        <el-table
          ref="multipleTableRef"
          :data="cusomerList.list"
          style="width: 100%"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" />
          <el-table-column property="userId" label="客户ID" width="100" />
          <el-table-column property="name" label="客户名" width="80" />
          <el-table-column property="account" label="客户IC" width="80" />
          <el-table-column property="" label="IC硬件" width="70" />
          <el-table-column property="" label="货号" width="70" />
          <el-table-column property="tem" label="手机号" width="70" />
          <el-table-column property="sex" label="性别" width="60" />
          <el-table-column label="编辑时间" width="164">
            <template #default="scope">{{ scope.row.date }}</template>
          </el-table-column>
          <el-table-column property="del" label="是否删除" width="80" />
          <el-table-column label="操作" style="text-align: center">
            <template #default><el-button size="small">删除</el-button></template>
          </el-table-column>
          <el-table-column label="修改">
            <template #default><el-button size="small">恢复</el-button></template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="titletext">客户信息</div>
    <div class="form">
      <el-form label-width="160px">
        <el-form-item label="货主编号">
          <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="货主名称">
          <el-input v-model="form.id" />
        </el-form-item>
        <el-form-item label="IC卡编号">
          <el-input v-model="form.pwd" type="password" />
        </el-form-item>
        <el-form-item label="固定电话">
          <el-input v-model="form.pwdi" type="password" />
        </el-form-item>
        <el-form-item label="手机号">
          <el-input v-model="form.pwdi" type="password" />
        </el-form-item>
        <el-form-item label="性别">
          <el-radio-group v-model="form.resource">
            <el-radio label="男" />
            <el-radio label="女" />
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="form.desc" rows="4" type="textarea" />
        </el-form-item>
        <el-form-item label="最后编辑时间">
          <el-col :span="11">
            <el-date-picker v-model="form.date1" type="date" />
          </el-col>
        </el-form-item>
        <el-form-item label="状态">
          <el-radio-group v-model="form.resource">
            <el-radio label="删除" />
            <el-radio label="活动" />
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">提交</el-button>
          <el-button>重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { reactive, ref } from "vue";
import type { ElTable } from "element-plus";
import { getUserList } from "@/api/system";

const search = reactive({
  user: "",
  id: "",
});
interface User {
  userId: number;
  name: string;
  account: string;
  officer?: string;
  tem: number;
  sex?: string;
  date?: string;
  del?: string;
}

const onSubmit = () => {
  console.log("submit!");
};

const multipleTableRef = ref<InstanceType<typeof ElTable>>();
const multipleSelection = ref<User[]>([]);
const handleSelectionChange = (val: User[]) => {
  multipleSelection.value = val;
};

const cusomerList = ref();

getUserList()
  .then((res) => {
    // console.log("用户管理", res.data);
    cusomerList.value = res.data;
    console.log("11", cusomerList.value);
  })
  .catch((err) => console.log(err));

const form = reactive({
  name: "",
  id: "",
  pwd: "",
  pwdi: "",
  region: "",
  date1: "",
  date2: "",
  delivery: false,
  type: [],
  resource: "",
  desc: "",
});
</script>
<style>
.list .is-leaf {
  text-align: center;
}
.list .el-table__cell {
  text-align: center;
}
.form .el-form-item__label {
  text-align: left;
  margin-right: 20px;
}
.form .el-input__inner {
  width: 200px;
}
.form .el-form-item--default {
  padding-left: 40px;
  margin-top: -10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
}
.form .el-textarea__inner {
  width: 400px;
}
.search .el-form-item--default {
  margin-right: 23px;
}
</style>
<style scoped>
.top {
  border: 1px solid #f2f2f2;
  margin-bottom: 20px;
  border-bottom: none;
}
.list {
  width: 100%;
}
.search {
  height: 50px;
  line-height: 65px;
  margin: 20px 20px 0;
  display: inline-block;
  background-color: #f2f2f2;
  padding-left: 20px;
}
.user {
  width: 1000px;
  min-width: 1000px;
  height: 85vh;
  margin: 10px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.titletext {
  color: #2e6095;
  height: 40px;
  line-height: 40px;
  padding-left: 25px;
  background-color: #f7f7f7;
  margin-bottom: 10px;
}
.form {
  background-color: #f2f2f2;
  padding-top: 20px;
}
</style>
